//
//  Check.m
//  CarCare
//
//  Created by ileo on 14-8-12.
//  Copyright (c) 2014年 baozun. All rights reserved.
//

#import "Check.h"
#import "SystemHelper.h"
#import "AIUserInfo.h"

@implementation Check

+(BOOL)isNoNull:(NSString *)string{
    if (![string isNotNil]) {
        [AlertMgr showShortWarnTextTips:@[@"请填写完整"]];
    }
    return [string isNotNil];
}

+(BOOL)isTel:(NSString *)tel{
    if (![tel isTel]) {
        if (![tel isNotNil]) {
            [AlertMgr showShortWarnTextTips:@[@"请先输入手机号"]];
        }
        else
        {
            [AlertMgr showShortNormalTextTips:@[@"请输入正确的手机号"]];
        }
    }
    return [tel isTel];
}

+(BOOL)isDevice:(NSString *)device{
    if (![device isDevice]) {
        if (![device isNotNil]) {
            [AlertMgr showShortWarnTextTips:@[@"请输入设备编码"]];
        }
        else
        {
            [AlertMgr showShortNormalTextTips:@[@"请扫描正确条形码或手动输入15位IMEI码"]];
        }
    }
    return [device isDevice];
}

+(BOOL)isDeviceCode:(NSString *)deviceCode{
    if (![deviceCode isDeviceCode]) {
        if (![deviceCode isNotNil]) {
            [AlertMgr showShortWarnTextTips:@[@"请输入CODE号"]];
        }
        else
        {
            [AlertMgr showShortNormalTextTips:@[@"请输入4位CODE码"]];
        }
    }
    return [deviceCode isDeviceCode];
}

+(BOOL)isPWD:(NSString *)pwd{
    if (![pwd isPWD]) {
        if (![pwd isNotNil]) {
            [AlertMgr showShortWarnTextTips:@[@"请输入密码"]];
        }
        else
        {
            [AlertMgr showShortNormalTextTips:@[@"密码是6～12位的数字和字母组合"]];
        }
    }
    return [pwd isPWD];
}
//支付宝账号
+(BOOL)isAli:(NSString *)ali{
    if (![ali isEmail] && ![ali isTel]) {
        if (![ali isNotNil]) {
            [AlertMgr showShortWarnTextTips:@[@"请输入支付宝账号"]];
        }
        else
        {
            [AlertMgr showShortNormalTextTips:@[@"账号必须是邮箱或者手机号"]];
        }
        return NO;
    }
    return YES;
}

+(BOOL)isIDCard:(NSString *)idCard{
    if (![idCard isIDCard]) {
        if (![idCard isNotNil]) {
            [AlertMgr showShortWarnTextTips:@[@"请输入身份证号"]];
        }
        else{
            [AlertMgr showShortNormalTextTips:@[@"请输入正确身份证号"]];
        }
        return NO;
    }
    return YES;
}
//短信验证码
+(BOOL)isCode:(NSString *)code{
    if (![code isCode]) {
        if (![code isNotNil]) {
            [AlertMgr showShortWarnTextTips:@[@"请输入短信验证码"]];
        }
        else
        {
            [AlertMgr showShortNormalTextTips:@[@"请输入正确的验证码"]];
        }
        return NO;
    }
    return YES;
}

+(BOOL)isNumOrBigASCII:(NSString *)string{
    if (![string isNumOrsASC]) {
        if (![string isNotNil]) {
            [AlertMgr showShortWarnTextTips:@[@"请输入车牌号"]];
        }else
        {
            [AlertMgr showShortNormalTextTips:@[@"车牌号格式有误"]];
        }
        return NO;
    }
    return YES;
}
+(BOOL)isNumOrBigASCIILength:(NSString *)string
{
    if (![Check isNumOrBigASCII:string]) {
        return NO;
    }else if(string.length < 6)
    {
        [AlertMgr showShortNormalTextTips:@[@"请输入正确的车牌号"]];
        return NO;
    }
    return YES;
}
+(BOOL)isNumOrBigASCIICarFrame:(NSString *)string
{
    if (![string isNumOrsASC]) {
        if (![string isNotNil]) {
            [AlertMgr showShortWarnTextTips:@[@"请输入车架号"]];
        }else
        {
            [AlertMgr showShortNormalTextTips:@[@"车架号格式有误"]];
        }
        
        return NO;
    }
    return YES;

}
+(BOOL)isNumOrBigASCIICarFrameLength:(NSString *)string
{
    if (![Check isNumOrBigASCIICarFrame:string]) {
        return NO;
    }else if(string.length < 7)
    {
        [AlertMgr showShortNormalTextTips:@[@"请输入正确的车架号"]];
        return NO;
    }
    return YES;
}
+(BOOL)isNumOrBigASCIIEngionNO:(NSString *)string
{
    if (![string isNumOrsASC]) {
        if (![string isNotNil]) {
            [AlertMgr showShortWarnTextTips:@[@"请输入发动机号"]];
        }else
        {
            [AlertMgr showShortNormalTextTips:@[@"发动机号格式有误"]];
        }
        
        return NO;
    }
    return YES;
}
+(BOOL)isNumOrBigASCIIEngionNOLength:(NSString *)string
{
    if (![Check isNumOrBigASCIIEngionNO:string]) {
        return NO;
    }else if(string.length < 4)
    {
        [AlertMgr showShortNormalTextTips:@[@"请输入正确的发动机号"]];
        return NO;
    }
    return YES;
}
+(BOOL)hasViolationTime{
    if (!SYSTEMHELPER.hasViolationTimes) {
        [AlertMgr showShortWarnTextTips:@[@"一天只能查询3次，请明天再查询吧"]];
    }
    return SYSTEMHELPER.hasViolationTimes;
}

#pragma mark -
+(BOOL)isVisiter{
    if (USERINFO.isVisiter) {
        TipsView *tips = [TipsView warnTipsWithTitle:nil lightTitles:@[@"体验模式下，无法使用该功能，",@"请谅解!"]];
        [tips addRedOkButton:@"确定" clickOK:^{
            [AlertMgr dismiss:TYPE_VIEW_ALERT];
        }];
        [AlertMgr showView:tips];
    }
    return USERINFO.isVisiter;
}


@end
